var daycontroller = {

    jsonValue : null,

    loadDayContent : function (){
        if (!window.plugins.readDBPlugin) {
            window.plugins.readDBPlugin = new readDBPlugin();
        }
        var result = window.plugins.readDBPlugin.getSets(daycontroller.success, daycontroller.error);
    },

    success : function(value){
        var output = "<ul>";
        var input = $.parseJSON(value);
        for(i=0; i<input.length; i++){
           output +="<li> Set "+input[i].set_num+" = "+input[i].reps_num+" reps</li>";
           localStorage.setItem("Set"+input[i].set_num,input[i].reps_num);
        }
        localStorage.setItem("SetsTotal",input.length);
        output+="</ul>";

        if(localStorage.getItem('day_num') == "1"){
            $("#day1_sets").html(output);
        }else if(localStorage.getItem('day_num') == "2"){
            $("#day2_sets").html(output);
        }else{
            $("#day3_sets").html(output);
        }
    },

    error : function(err){
        jsonValue = err;
        //alert("fail");
    },

    getJSONValue : function(){
        return jsonValue;
    }

}
